﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Globalization;
using System.Runtime.Serialization;
namespace GSLMS.Entity
{
	/// <summary>
	/// 2.3.54    贷款预收退款信息表
	/// </summary>
	[DataContract(IsReference = true)]
	public partial class TB_LOAN_ADVRECBACK: IObjectWithChangeTracker, INotifyPropertyChanged
	{
		public TB_LOAN_ADVRECBACK()
		{}
		#region Model
		private long _id;
		private long _advrecid;
		private int _backtype;
		private decimal _backamt;
		private Nullable<DateTime> _backdate;
		private string _exchangeno;
		private string _createby;
		private Nullable<DateTime> _createdate;
		private string _remark;
		private long _returnid;
		/// <summary>
		/// 记录ID唯一
		/// </summary>
		[DataMember]
		public long ID
		{
			get{return _id;}
			set{
				if ( _id!= value)
				{
					if (ChangeTracker.ChangeTrackingEnabled && ChangeTracker.State != ObjectState.Added)
					{
						throw new InvalidOperationException("属性“ID”是对象键的一部分，不可更改。仅当未跟踪对象或对象处于“已添加”状态时，才能对键属性进行更改。");
					}
					 _id = value;
					OnPropertyChanged("ID");
				}
			}
		}
		/// <summary>
		/// 预收款记录ID
		/// </summary>
		[DataMember]
		public long ADVRECID
		{
			get{return _advrecid;}
			set{
				if ( _advrecid!= value)
				{
					 _advrecid = value;
					OnPropertyChanged("ADVRECID");
				}
			}
		}
		/// <summary>
		/// 类型1退款，2抵扣
		/// </summary>
		[DataMember]
		public int BACKTYPE
		{
			get{return _backtype;}
			set{
				if ( _backtype!= value)
				{
					 _backtype = value;
					OnPropertyChanged("BACKTYPE");
				}
			}
		}
		/// <summary>
		/// 退款金额
		/// </summary>
		[DataMember]
		public decimal BACKAMT
		{
			get{return _backamt;}
			set{
				if ( _backamt!= value)
				{
					 _backamt = value;
					OnPropertyChanged("BACKAMT");
				}
			}
		}
		/// <summary>
		/// 退款日期
		/// </summary>
		[DataMember]
		public Nullable<DateTime> BACKDATE
		{
			get{return _backdate;}
			set{
				if ( _backdate!= value)
				{
					 _backdate = value;
					OnPropertyChanged("BACKDATE");
				}
			}
		}
		/// <summary>
		/// 水单号
		/// </summary>
		[DataMember]
		public string EXCHANGENO
		{
			get{return _exchangeno;}
			set{
				if ( _exchangeno!= value)
				{
					 _exchangeno = value;
					OnPropertyChanged("EXCHANGENO");
				}
			}
		}
		/// <summary>
		/// 录入人
		/// </summary>
		[DataMember]
		public string CREATEBY
		{
			get{return _createby;}
			set{
				if ( _createby!= value)
				{
					 _createby = value;
					OnPropertyChanged("CREATEBY");
				}
			}
		}
		/// <summary>
		/// 录入时间
		/// </summary>
		[DataMember]
		public Nullable<DateTime> CREATEDATE
		{
			get{return _createdate;}
			set{
				if ( _createdate!= value)
				{
					 _createdate = value;
					OnPropertyChanged("CREATEDATE");
				}
			}
		}
		/// <summary>
		/// 备注
		/// </summary>
		[DataMember]
		public string REMARK
		{
			get{return _remark;}
			set{
				if ( _remark!= value)
				{
					 _remark = value;
					OnPropertyChanged("REMARK");
				}
			}
		}
		/// <summary>
		/// 收回记录ID
		/// </summary>
		[DataMember]
		public long RETURNID
		{
			get{return _returnid;}
			set{
				if ( _returnid!= value)
				{
					 _returnid = value;
					OnPropertyChanged("RETURNID");
				}
			}
		}
		#endregion Model

	#region ChangeTracking
	   
	protected virtual void OnPropertyChanged(String propertyName)
	{
	    if (ChangeTracker.State != ObjectState.Added && ChangeTracker.State != ObjectState.Deleted)
	    {
	        ChangeTracker.State = ObjectState.Modified;
	    }
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	protected virtual void OnNavigationPropertyChanged(String propertyName)
	{
	    if (_propertyChanged != null)
	    {
	        _propertyChanged(this, new PropertyChangedEventArgs(propertyName));
	    }
	}
	   
	event PropertyChangedEventHandler INotifyPropertyChanged.PropertyChanged{ add { _propertyChanged += value; } remove { _propertyChanged -= value; } }
	private event PropertyChangedEventHandler _propertyChanged;
	private ObjectChangeTracker _changeTracker;
	   
	[DataMember]
	public ObjectChangeTracker ChangeTracker
	{
	    get
	    {
	        if (_changeTracker == null)
	        {
	            _changeTracker = new ObjectChangeTracker();
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	        return _changeTracker;
	    }
	    set
	    {
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging -= HandleObjectStateChanging;
	        }
	        _changeTracker = value;
	        if(_changeTracker != null)
	        {
	            _changeTracker.ObjectStateChanging += HandleObjectStateChanging;
	        }
	    }
	}
	   
	private void HandleObjectStateChanging(object sender, ObjectStateChangingEventArgs e)
	{
	    if (e.NewState == ObjectState.Deleted)
	    {
	        ClearNavigationProperties();
	    }
	}
	   
	protected bool IsDeserializing { get; private set; }
	   
	[OnDeserializing]
	public void OnDeserializingMethod(StreamingContext context)
	{
	    IsDeserializing = true;
	}
	   
	[OnDeserialized]
	public void OnDeserializedMethod(StreamingContext context)
	{
	    IsDeserializing = false;
	    ChangeTracker.ChangeTrackingEnabled = true;
	}
	   
	protected virtual void ClearNavigationProperties()
	{
	}
	
	#endregion

	}
}

